<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
    <h4 class="modal-title" id="myModalLabel">属性添加</h4>
</div>
<form class="form-horizontal J_ajaxForm" role="form" method="post" action="" data-validate="validate">
    <div class="modal-body">
        <div class="form-group">
            <label class="col-sm-3 control-label">属性名称</label>
            <div class="col-sm-9">
                <input type="text" class="form-control" placeholder="属性名称" name="name">
                <!--<p class="help-block">必填</p>-->
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">分类</label>
            <div class="col-sm-9">
                <select class="form-control" id="storage" name="storage">
                    <option value="-1">请选择</option>
                    <option value="0">冰鲜</option>
                    <option value="1">冻品</option>
                    <option value="2">远洋</option>
                    <option value="3">已加工</option>
                    <option value="4">养殖</option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">显示顺序</label>
            <div class="col-sm-3">
                <input type="text" class="form-control" placeholder="显示顺序" name="sort" value="0">(越大显示越靠前)
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">状态</label>
            <div class="col-sm-9">
                <select class="form-control" name="state">
                    <option value="0">不显示</option>
                    <option value="1" selected>显示</option>
                </select>
            </div>
        </div>

    </div>
    <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
        <button type="button" class="btn btn-primary J_ajaxSubmitBtn">提交</button>
    </div>
</form>

<script>

    $(document).ready(function () {

        $("form").attr("action", common_conf.requestUrl+'attribute/add');
    });

    function validate($from) {
        var name = $from.find('input[name="name"]');
        if ($.trim(name.val()) == '') {
            return '属性名称不能为空';
        }
        var storage=$('#storage option:selected').val();

        if(storage==-1){
            return "请选择分类";
        }
        return true;
    }
</script>